#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   set.py
@Time    :   2024-07-09 13:02:38
@Author  :   chakcy 
@Email   :   947105045@qq.com
@description   :   redis set 操作
'''

from redis.asyncio import Redis

class RedisSet:
    def __init__(self, redis: Redis):
        """初始化 Redis 连接"""
        self.redis = redis
    async def get_value(self, key: str): 
        """获取指定键的所有成员"""
        return self.redis.smembers(key) 
    async def set_value(self, key: str, value: str): 
        """添加值到集合"""
        return self.redis.sadd(key, value) 
    async def delete_value(self, key: str, value: str): 
        """删除指定值"""
        return self.redis.srem(key, value) 
    async def get_all_values(self, key: str): 
        """获取指定键的所有成员"""
        return self.redis.smembers(key) 